package com.llpy.Utils;

import com.mongodb.WriteConcern;
import com.mongodb.client.MongoClient;
import com.mongodb.client.gridfs.GridFSBucket;
import com.mongodb.client.gridfs.GridFSBuckets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GridFSUtils {
    private final MongoClient mongoClient;

    @Autowired
    public GridFSUtils(MongoClient mongoClient) {
        this.mongoClient = mongoClient;
    }

    public GridFSBucket getGridFSBucket(String bucketName) {
        return GridFSBuckets.create(mongoClient.getDatabase("Mydata"), bucketName);
    }
}